package com.wash.shoes.context;

/**
 * 数据权限上下文
 */
public class DataPermissionContext {
    private static final ThreadLocal<DataPermissionInfo> DATA_PERMISSION_HOLDER = new ThreadLocal<>();

    public static DataPermissionInfo getDataPermissionInfo() {
        return DATA_PERMISSION_HOLDER.get();
    }

    public static void setDataPermissionInfo(DataPermissionInfo dataPermissionInfo) {
        DATA_PERMISSION_HOLDER.set(dataPermissionInfo);
    }

    public static void clear() {
        DATA_PERMISSION_HOLDER.remove();
    }

    public static class DataPermissionInfo {
        private String type;
        private String field;
        private String tableAlias;
        private String permissionSql;

        // 构造器、getter和setter方法
        public DataPermissionInfo(String type, String field, String tableAlias) {
            this.type = type;
            this.field = field;
            this.tableAlias = tableAlias;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getField() {
            return field;
        }

        public void setField(String field) {
            this.field = field;
        }

        public String getTableAlias() {
            return tableAlias;
        }

        public void setTableAlias(String tableAlias) {
            this.tableAlias = tableAlias;
        }

        public String getPermissionSql() {
            return permissionSql;
        }

        public void setPermissionSql(String permissionSql) {
            this.permissionSql = permissionSql;
        }
    }
}